/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  TokenTagFreemarker.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-14 下午8:40:19
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-14          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.web.tag;

import java.util.List;

import org.cloudland.web.tag.support.TokenHelper;

import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;


 /**
 * <pre> 
 * 在页面的form下放置token标签定义类。
 * </pre>
 * @ClassName  TokenTagFreemarker
 * @author  lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class TokenTagFreemarker implements TemplateMethodModel {

	/**
	 * @param arguments
	 * @return
	 * @throws TemplateModelException
	 */
	@SuppressWarnings("rawtypes")
	public Object exec(List arguments) throws TemplateModelException {
		
		String tokenValue = TokenHelper.getToken();
        StringBuffer pageString = new StringBuffer("<input type=\"hidden\" name=\"").append(TokenHelper.DEFAULT_TOKEN_NAME).append("\" value=\"");
        pageString.append(tokenValue).append("\"/>");
        return pageString.toString();
	}
}
